package com.biz.primus.ms.oms.dao.po;

import com.biz.primus.ms.base.jpa.po.BaseEntity;
import lombok.Data;

import javax.persistence.*;
import java.util.List;

/**
 *
 * 商品项
 * 组合商品/整箱商品会拆分为单个商品
 * @author yanweijin
 * @date 2017/6/17
 */

@Data
@Entity
@Table(name = "oms_order_item",indexes = {
		@Index(name = "idx_product_code",columnList = "productCode"),
		@Index(name = "idx_item_code",columnList = "itemCode")
})
public class OmsOrderItem extends BaseEntity {



	private String itemCode;

	@ManyToOne
	private OmsOrder order;

	@Column(length = 200)
	private String productName;

	/**
	 * 标价(单价)
	 */
	private Integer marketPrice = 0;

	/**
	 * 原价(单价)
	 */
	private Integer price = 0;

	/**
	 * 最终售价(分摊各种促销/优惠之后)(单价)
	 */
	private Integer finalPrice = 0;

	/**
	 * 商品图片缩略图key(oss key)
	 */
	@Column(length = 200)
	private String logo;

	/**
	 * 商品分类编号
	 */
	private String categoryCode;

	/**
	 * 品牌编号
	 */
	private String brandCode;

	/**
	 * 商品条码
	 */
	private String barcode;

	/**
	 * 购买数量
	 */
	private Integer quantity = 0;

	/**
	 * 商品编号
	 */
	@Column(length = 64, nullable = false)
	private String productCode;

	/**
	 * 重量,克
	 */
	private Integer weight = 0;

	private Integer usePoint;

	/**
	 * 折扣总金额,单位分
	 * ( (price-finalPrice)*quantity == discountPop + discountCoupon + discountGrant == discountAmount)
	 */
	private Integer discountAmount = 0;
	/**
	 * 促销折扣
	 */
	private Integer discountPop = 0;
	/**
	 * 优惠券折扣
	 */
	private Integer discountCoupon = 0;
	/**
	 * 临时折扣
	 */
	private Integer discountGrant = 0;





	/**
	 * 商品项分摊信息
	 */
	@OneToMany(mappedBy = "item", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
	private List<OrderItemApportionment> apportionmentInfo;

	@Column(columnDefinition = "TEXT")
	private String couponOriginData;
	@Column(columnDefinition = "TEXT")
	private String promotionOriginData;





}
